﻿using System;
using System.Configuration;
using System.Web;
using System.Web.UI;
using Cms.Application;
using iLib.Web.UI;

namespace Cms.Web.UI.Admin
{
    public partial class ProcessUpgrade : Page, ITranslatable
    {
        #region ITranslatable Members

        public string ContextTranslationFile
        {
            get { return "Admin/Translations/ProcessUpgrade.xml"; }
        }


        public string Localization
        {
            get { return (string) (ViewState["Localization"] ?? "en-US"); }
            set { ViewState["Localization"] = value; }
        }

        #endregion

        protected override void OnLoad(EventArgs e)
        {
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now.AddSeconds(-10));
            Response.Cache.SetValidUntilExpires(false);
            Response.Cache.VaryByParams.IgnoreParams = false;
            Header.Controls.AddAt(0, new LiteralControl("<base href=\"" + Url.FullPath + "\" />"));
            if (Page.IsPostBack)
                return;
            form1.Action = Url.FoldersAndPage + Url.Querystring;
            litVersion.Text = Request.QueryString["LatestVersion"];
            Page.ClientScript.RegisterStartupScript(GetType(), "startUpgrade", "startUpgrade('" + Url.FullPath + "');",
                                                    true);
            hidManualRestarts.Value =
                !string.IsNullOrEmpty(ConfigurationManager.AppSettings["AspNetIsRestartedManually"])
                    ? ConfigurationManager.AppSettings["AspNetIsRestartedManually"]
                    : "false";
            pnlManualRestart.Visible = hidManualRestarts.Value == "true";
        }
    }
}